﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ClassList.aspx.cs" Inherits="School_ClassList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>班级列表</title>
    
    <link href="../Common/css/main.css" rel="stylesheet" type="text/css" />    
    <script type="text/javascript" src="../Common/Js/jquery.js"></script>
    <script type="text/javascript" src="../Common/Js/common.js"></script>
    <script type="text/javascript" src="../Common/Js/msg.js"></script>
    <script type="text/javascript" src="../Common/Js/xTree/dhtmlxcommon.js"></script>
    <script type="text/javascript" src="../Common/Js/xTree/dhtmlxtree.js"></script>
    <link href="../Common/css/dhtmlxtree.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" >

window.onload = InitClassList;

var activate = 1;
var tree;

function InitClassList()
{
    tree=new dhtmlXTreeObject('treeBox',"100%","100%",0);
    tree.setImagePath("../Common/images/xTreeImgs/");
    
    var id, text, firstId=0;
    PageMethods.GetSchoolType(function(succ)
    {
        if (succ > 0)
        {
             var arrGrade = GetGradeInfo(succ);
             for (var i=0; i<arrGrade.length; i++)
             {
                
                tree.insertNewChild(0, arrGrade[i].gradeIndex-2*arrGrade[i].gradeIndex, arrGrade[i].gradeName,0,
                                    "group.gif","group.gif","group.gif","");
             }
             
             PageMethods.InitClassList(function(succ)
             {               
                if (succ.length > 0)
                {
                    var parentId = 0;
                    for(var j = 0; j<succ.length; j++)
                    {
                        parentId = succ[j].Grade - 2*succ[j].Grade;
                        if (firstId == 0)
                            firstId = succ[j].RID;
                        
                        tree.insertNewChild(parentId, succ[j].RID,succ[j].ClsName, 0, "group.gif", "group.gif", "group.gif", "");
                    } 
                }
                
                tree.setOnClickHandler(treeOnClick);
                
                if (firstId > 0)
                {
                    self.parent.currClass = firstId;
                    tree.selectItem(self.parent.currClass, true);
                    self.parent.frames["right"].location  = "StudentGrid.aspx?id=" + self.parent.currClass;
                }
                             
             },function(err)
             {
                self.parent.showMassgeBox("提示","获取班级信息失败，请刷新后重试",1,null); 
             })
        }
    },function(err)
    {
        self.parent.showMassgeBox("提示","获取学校性质失败，请刷新后重试",1,null); 
    }
    )
}
    
    //过滤用户信息，根据教研组分类
function treeOnClick(id)
{
    if(activate == 0)
    {
        tree.selectItem(self.parent.currClass, false);
        self.parent.frames["right"].showMassgeBox('提示','您还有未保存的项,请保存后再切换班级');
        return;
    }

    if(id > 0)
    {
        self.parent.currClass = id;
        self.parent.frames["right"].location  = "StudentGrid.aspx?id="+id;
    }
    else
    {
        if(self.parent.currClass != null && self.parent.currClass > 0)
           tree.selectItem(self.parent.currClass, false);
    }
}


    
</script>

</head>
<body>
<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
         
	        <div class="oneTreeBody">
                    <div class="treeMain">
                         <div style="height:95%; width:170px; overflow:auto;" id="treeBox"></div>
      		        </div>
            </div> 
            
         </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
